package com.paradogs.framework.core.msg;

import com.paradogs.framework.core.annoations.request.PRController;
import com.paradogs.framework.core.annoations.request.PRMsgMapping;
import com.paradogs.framework.core.events.RPCRespEvent;
import com.paradogs.framework.core.utils.EventUtils;
import lombok.extern.slf4j.Slf4j;

/**
 * @author: yumi
 * @date: 2023/8/7  16:04
 * @Description: TODO
 */
@Slf4j
@PRController
@PRMsgMapping("_paradogs")
public class CommonController {

    @PRMsgMapping("dist")
    public void dist() {
        log.info("dist test success ...");
    }

    /**
     * 回调处理，通知回调事件
     * GC 消息统一走这里，保证也按队列顺序处理
     * @param msg
     */
    @PRMsgMapping("callback")
    public void callback(ByteData msg) {
        if (msg.getMsgHeader().getReplyMsgId() == null) {
            log.error("Not found Callback header.replyMsgId: {}", msg);
            return;
        }
        EventUtils.publishEvent(new RPCRespEvent(msg));
    }

}
